package com.easyexcle.demo.easyExcel.collect;

import com.alibaba.excel.EasyExcel;
import com.easyexcle.demo.easyExcel.style.CustomMergeStrategy;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @Author: lkz
 * @Title: CollectTest
 * @Description: 一对多集合测试
 * @Date: 2023/7/5 9:21
 */

public class CollectTest {


    public static void main(String[] args) {
        /**
         * 这里的数据要注意一下.主键相同的要紧挨着放入，不然不放咋一起还是不能合并
         */
        List<OrderData> orderDataList=new ArrayList<>();
        orderDataList.add(new OrderData("1",new Date(),"南京","001","商品名称1","标题1"));
        orderDataList.add(new OrderData("1",new Date(),"南京2","001","商品名称2","标题2"));
        orderDataList.add(new OrderData("1",new Date(),"南京3","001","商品名称2","标题3"));
        orderDataList.add(new OrderData("2",new Date(),"北京","002","商品名称02","标题02"));
        orderDataList.add(new OrderData("2",new Date(),"北京","003","商品名称03","标题1"));
        orderDataList.add(new OrderData("1",new Date(),"南京","001","商品名称3","标题3"));
        orderDataList.add(new OrderData("3",new Date(),"上海","001","商品名称3","标题3"));
        orderDataList.add(new OrderData("3",new Date(),"天津","001","商品名称302","标题302"));
        orderDataList.add(new OrderData("3",new Date(),"上海2","0012","商品名称3032","标题303"));
        orderDataList.add(new OrderData("3",new Date(),"上海3","0013","商品名称3033","标题303"));
        orderDataList.add(new OrderData("3",new Date(),"上海4","0014","商品名称3034","标题303"));
        orderDataList.add(new OrderData("3",new Date(),"上海5","0015","商品名称3035","标题303"));
        orderDataList.add(new OrderData("4",new Date(),"杭州","001","商品名称4","标题4"));
        orderDataList.add(new OrderData("5",new Date(),"杭州","001","商品名称5","标题5"));


        EasyExcel.write("D:/pdf/CollectExport.xlsx").head(OrderData.class)
                .registerWriteHandler(new CustomMergeStrategy(OrderData.class))
                .sheet().doWrite(orderDataList);

    }



}
